﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using SIMSProject.Common;
namespace SIMSProject.Views.Ajax.AjaxPermission
{
    public partial class AjaxPermissionUserControl : UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string strReturn = ";";
            SPWeb web = SPContext.Current.Web;
            if(web.Lists.TryGetList(Constant.ListName.Material)!=null) strReturn+= Constant.ListName.Material + ";";
            if ( web.Lists.TryGetList(Constant.ListName.Product) != null) strReturn += Constant.ListName.Product + ";";
            if ( web.Lists.TryGetList(Constant.ListName.MaterialRequest) != null) strReturn += Constant.ListName.MaterialRequest + ";";
            if ( web.Lists.TryGetList(Constant.ListName.MaterialTracking) != null) strReturn += Constant.ListName.MaterialTracking + ";";
            if ( web.Lists.TryGetList(Constant.ListName.Order) != null) strReturn += Constant.ListName.Order + ";";
            if ( web.Lists.TryGetList(Constant.ListName.ProductTracking) != null) strReturn += Constant.ListName.ProductTracking + ";";
            if ( web.Lists.TryGetList(Constant.ListName.Provider) != null) strReturn += Constant.ListName.Provider + ";";
            if ( web.Lists.TryGetList(Constant.ListName.Customer) != null) strReturn += Constant.ListName.Customer + ";";
            if(web.IsCurrentUserMemberOfGroup(web.Groups["Administrator"].ID)) strReturn +="Administrator"+";";
            if (web.IsCurrentUserMemberOfGroup(web.Groups[Constant.Groups.Director].ID) || web.IsCurrentUserMemberOfGroup(web.Groups[Constant.Groups.SalesManager].ID)) strReturn += "Sale Report" + ";";
            if (web.IsCurrentUserMemberOfGroup(web.Groups[Constant.Groups.InventoryManager].ID) || web.IsCurrentUserMemberOfGroup(web.Groups[Constant.Groups.Director].ID)) strReturn += "Inventory Report;";
            if (web.IsCurrentUserMemberOfGroup(web.Groups[Constant.Groups.InventoryManager].ID)) strReturn +="Import Data;";
            Response.Write(strReturn);
        }
    }
}
